from forest.resource import Resources, Resource, ValidationError
from forest.resources.common import translate_disk_name

class Bootloader(Resource):
    ''' Installs grub on the mbr on all specified devices.

        Specifies the target disk(s), disks to skip and additional
        grub2-install parameters.

        Example::

            resources:
              - $: bootloader
                device: [disk1, disk2]

        .. describe :: device[*]

            A list of target disks to be made bootable.
    '''
    __register__ = "bootloader"

    def get_device(self):
        return translate_disk_name(self.config, self.value.get('device'))

    def get_id(self):
        return 'bootloader:'+str(self.value.get('device'))
